﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using InPatientCntroller;

namespace HPMDesktop.Patient.Controls
{
    public partial class PatientBillingControl : UserControl
    {
        public PatientBillingControl()
        {
            InitializeComponent();
        }

        private void PatientBillingControl_Load(object sender, EventArgs e)
        {
            string CRNumber;

            CRNumber = "AX101";

                PatientBilling objData = new PatientBilling();
                PatientBilling_DataLoader objDataLoader = new PatientBilling_DataLoader();

                try
                {

                    objData = objDataLoader.Get_PatientBilling_DATA(CRNumber);

                    RcptNumber.Text = Convert.ToString(objData.RcptNumber);
                    ChargeType.Text = Convert.ToString(objData.ChargeType);
                    Quantity.Text = Convert.ToString(objData.Quantity);
                    Rate.Text = Convert.ToString(objData.Rate);
                    Amount.Text = Convert.ToString(objData.Amount);
                    AmountPaid.Text = Convert.ToString(objData.AmountPaid);
                    DiscountType.Text = Convert.ToString(objData.DiscountType);
                    RecomandedBy.Text = Convert.ToString(objData.RecomandedBy);
                }
                catch (Exception ex)
                {

                }
                finally
                {
                    objData.Dispose();
                    objDataLoader.Dispose();

                }
            
        }

        private void cmdSave_Click(object sender, EventArgs e)
        {
            bool result;
            string CRNumber = "AX101";
            PatientBilling objData = new PatientBilling();
            PatientBilling_Mapper objMapper = new PatientBilling_Mapper();

            try
            {
                objData.CRNumber = Convert.ToString(CRNumber);
                objData.RcptNumber = Convert.ToString(RcptNumber.Text);
                objData.ChargeType = Convert.ToString(ChargeType.Text);
                objData.Quantity = Convert.ToDouble(Quantity.Text);
                objData.Rate = Convert.ToDouble(Rate.Text);
                objData.Amount = Convert.ToDouble(Amount.Text);
                objData.AmountPaid = Convert.ToDouble(AmountPaid.Text);
                objData.DiscountType = Convert.ToString(DiscountType.Text);
                objData.RecomandedBy = Convert.ToString(RecomandedBy.Text);

                result = objMapper.Load_PatientBilling_DATA(objData.CRNumber, objData);
            }
            catch (Exception ex)
            {

            }
            finally
            {
                objData.Dispose();
                objMapper.Dispose();

            }

        }

        private void cmdCancel_Click(object sender, EventArgs e)
        {
            //this.Close();
        }
    }
}
